<%--
 *  File:    SalesBehavior.jsp
 *  @Author: banshang
 *  Date:    2010/07/08
 *
 *  Copyright (C) 2000 - 2002 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="org.apache.log4j.Category" %>
<%@ page import="com.oval.util.*" %>

<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>


<% //--------------------------------------  setting logger --%>


<% //--------------------------------------  variant and initialization --%>
<%
	String strModuleName = "COM";
 	String strTableName = "v_salesbehaviour";
	String privilegeCode = "11101";    
    String contextPath = request.getContextPath(); 
%>

<% //--------------------------------------  include files list --%>

<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/FrmDefault.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<%@ include file="/inc/LocationDefault.inc" %>
<html>
<head>
<title>SalesBehaviour</title>
<PageFlow:CheckPageFlow pageName="p_salesbehaviour"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/FuncLib.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>

<%@ include file="/inc/SummaryDivision.inc" %>

<% //--------------------------------------  output variant from pageflow --%>
<%
  	Vector totalsummary = (Vector)pageContext.getAttribute("totalsummary");
  	if(totalsummary == null)
  	{
  		totalsummary = new Vector();
  	}
%>



<script language="JavaScript" >
function page_summary(actionvalue,orderbyname){
  	 var editform = summaryPrepare(cform,actionvalue,orderbyname);
 	 editform.action = "SalesBehavior.jsp?<%= OvalTools.randomURL() %>";
 	 editform.target = "_self";
 	 isRunning = true;
 	 editform.submit();
}

function checkSalesQty(){
	var salesqty = document.cform.salesqty.value;
	var qtyReg = /^[<|>][=|\d]\d+$/;
	var isDigit = /^\d+$/;
	if(isDigit.test(salesqty)){
		return true
	}else{
		if(qtyReg.test(salesqty)){
			return true;
		}
		alert('<%= message.getMessageDesc("A_Must_Like_B",label.getLabelName("L_SalesQty"),">/>=/</<=/数字") %>');
		return false;	
	}
}

function page_add(){
	if(!checkSalesQty()) return;
	 if(!checkForm(cform)) return;
	 
	 cform.actionname.value = "add";
  	 cform.target = "_self";
  	 isRunning = true;
  	 cform.submit();
}

function page_delete(){
    if(isNullChecked(cform.deleteids))
    {
        alert("<%= message.getMessageDesc("MUST_SELECT_ONE_RECORD_TO_DEL") %>");
        return;
    }
    if(!confirm("<%= message.getMessageDesc("ARE_YOU_SURE_DEL") %>")) return;
    
    cform.actionname.value = "delete";
    cform.target = "_self";
    isRunning = true;
	cform.submit();
}
function page_setproduct(id,umcode,prodcode,prodname){
	document.cform.prodid.value=id;
	document.cform.productname.value=prodname;
}

function allcheckselect(){
	var allcheck = cform.allcheck.checked;
	var alldatafile = document.getElementsByName('deleteids');
	var length = alldatafile.length;
	if(allcheck){
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = true;
		}
	}else{
		for(var i = 0 ; i < length;i++){
			alldatafile[i].checked = false;
		}	
	}
}

</script>

</head>
<body>
<% //--------------------------------------  page location --%>
	<%@ include file="/inc/PageLocation.inc" %>
<table width="100%" cellspacing="0" border="0" cellpadding="0">
<form name="cform" method="post" action="<%=contextPath %>/Dispatcher"  target="_self">
	<input type="hidden" name="pagename" value="p_salesbehaviour">
	<input type="hidden" name="actionname">
   	<tr>
     	<td>
     		<table width="100%" border="0" cellspacing="0">
				<%@ include file="/inc/SummarySearch.inc" %>		
		    </table>
     	</td>
    </tr>
    <tr> 
	    <td> 
	      <table width="100%" border="1" cellpadding="0" bordercolorlight="#999999" bordercolordark="#FFFFFF" cellspacing="0" align="center">
	         <tr class="deepblue-left" >
			  <td width="2%" class="title_center"><input type="checkbox" name="allcheck" class="normalradio" onclick="allcheckselect();"></td>
	          <td class="title_center" width="5%"><a href="javascript:page_summary('orderby','seller')"><%= label.getLabelName("L_ComSeller") %></a>&nbsp;<span class='red'>*</span></td>
	          <td class="title_center" width="5%" ><a href="javascript:page_summary('orderby','buyer')"><%= label.getLabelName("L_ComBuyer") %></a>&nbsp;<span class='red'>*</span></td>
	          <td class="title_center" width="9%"><a href="javascript:page_summary('orderby','iffitsalesarea')"><%= label.getLabelName("L_Whether_The_Sales_area") %></a></td>
	          <td class="title_center" width="9%"><a href="javascript:page_summary('orderby','issameprovincial')"><%= label.getLabelName("L_Province_Are_Consistent") %></a></td>
	          <td class="title_center" width="9%"><a href="javascript:page_summary('orderby','hassalesprotocol')"><%= label.getLabelName("L_IsProtocal") %></a></td>
	          <!-- <td class="title_center" width="9%"><a href="javascript:page_summary('orderby','issamearea')"><%= label.getLabelName("L_Business_District") %></a></td> -->
	          <td class="title_center" width="9%"><a href="javascript:page_summary('orderby','salesqty')"><%= label.getLabelName("L_Sales_Quantity_Standard") %></a></td>
	          <td class="title_center" width="9%"><a href="javascript:page_summary('orderby','salesbehaviour')"><%= label.getLabelName("L_SalesBehaviour") %></a>&nbsp;<span class='red'>*</span></td>
	          <td class="title_center" width="9%"><a href="javascript:page_summary('orderby','salesledger')"><%= label.getLabelName("L_Sales_Classify") %></a></td>
	        </tr>
	        <%
            	int i = 0;
             	String strClassType = new String();
          	%>
	         <logic:iterate id="onerow" collection="<%= totalsummary %>" indexId="idx">
	           	<%
	            	HashMap tempMap = (HashMap)pageContext.getAttribute("onerow");
	            	if(i%2 == 1)
	            	{
	              		strClassType = "td-listrom";
	            	}else{
	              		strClassType = "";
	            	}
	            	i++;
	          	%>
	          	<tr onMouseOver="this.className='tr-over'" onMouseOut="this.className='<%=JspHelper.filterNull( strClassType )%>'"  class="none">
	          		<td class="title_center" >
	              		<input type="checkbox" name="deleteids" value="<%=JspHelper.filterNull( tempMap.get("salesbehaviourid") )%>" class="checkbox">
	            	</td>
	            	<td class="title_center">
	            		<custom:write name="onerow" property="seller" dictType="InstitutionalType" nbsp="true"/>
	            	</td>
	            	<td class="title_center">
	            		<custom:write name="onerow" property="buyer" dictType="InstitutionalType" nbsp="true"/>
	            	</td>
	                <td class="title_center">
						<custom:write name="onerow" property="iffitsalesarea" dictType="YesOrNo" nbsp="true"/>
					</td> 
					<td class="title_center">
						<custom:write name="onerow" property="issameprovincial" dictType="YesOrNo" nbsp="true"/>
					</td> 
					<td class="title_center">
						<custom:write name="onerow" property="hassalesprotocol" dictType="YesOrNo" nbsp="true"/>
					</td> 
					<!-- <td class="title_center">
						<custom:write name="onerow" property="issamearea" dictType="YesOrNo" nbsp="true"/>
					</td>  -->
					<td class="title_center">
	            		<custom:write name="onerow" property="salesqty" nbsp="true"/>
	            	</td>
					<td class="title_center">
					    <custom:write name="onerow" property="salesbehaviour" dictType="SalesBehavior" nbsp="true"/>
	     		        <custom:hidden name="onerow" property="salesbehaviourid" colIndex="<%= idx %>"/>
	     		    </td>
	     		    <td class="title_center">
					    <custom:write name="onerow" property="salesledger" dictType="SalesLedger" nbsp="true"/>
	     		        <custom:hidden name="onerow" property="salesledger" colIndex="<%= idx %>"/>
	     		    </td>
	     		 </tr>
	     	 </logic:iterate>
	     	 <tr class="none">
	           <td>&nbsp;</td>
	           <td>
	           	<custom:selectdic property="seller" dictType="InstitutionalType" command="notnull" label="L_ComSeller" defaultValueCost=" " defaultValue="--------------"/>
	           </td>
	           <td>
	           	<custom:selectdic property="buyer" dictType="InstitutionalType" command="notnull" label="L_ComBuyer" defaultValueCost=" " defaultValue="--------------"/>
			   </td>
			   <td class="title_center">
	           	<custom:selectdic property="iffitsalesarea" dictType="YesOrNo" defaultValueCost=" " defaultValue="----"/>
	           </td>
	            <td class="title_center">
	           	<custom:selectdic property="issameprovincial" dictType="YesOrNo" defaultValueCost=" " defaultValue="----"/>
	           </td>
	           <td class="title_center">
	           	<custom:selectdic property="hassalesprotocol" dictType="YesOrNo" defaultValueCost=" " defaultValue="----"  />
	           </td>
	           <!-- <td class="title_center">
	           	<custom:selectdic property="issamearea" dictType="YesOrNo" defaultValueCost=" " defaultValue="----"/>
	           </td> -->
	           <td class="title_center">
	           	<custom:text property="salesqty"></custom:text>
	           </td>
	           <td class="title_center">
	           	<custom:selectdic property="salesbehaviour" dictType="SalesBehavior" command="notnull" label="L_SalesBehaviour" defaultValue="--------------" defaultValueCost=" "/>
	           </td>
	           <td class="title_center">
	           	<custom:selectdic property="salesledger" dictType="SalesLedger"  label="L_Sales_Classify" defaultValue="--------------" defaultValueCost=" "/>
	           </td>
		     </tr>
	      <%@ include file="/inc/SummaryAction.inc" %>
	      </table>
	      <table width="100%" cellspacing="0" cellpadding="0">
	        <tr> 
	          <td class="summary_top"></td>
	        </tr>
	        <tr>
			     <td class="td_center">
					<a onclick="page_add()"><custom:button type="1" label="L_Add" imgsrc="add.gif" border="0" style="width:60" privilegeCode="MB-XSXW01"/></a>
					<%if(totalsummary.size() >0 ){%>
					<a onclick="page_delete()"><custom:button type="1" label="L_Delete" imgsrc="delete.gif" border="0" style="width:60" privilegeCode="MB-XSXW02"/></a>
					<%} %>
				 </td>
			</tr>
	      </table>
	    </td>
  </tr>
  </form>
</table>
</body>
</html>